<template>
  <div class="system_info">
    <h3>{{ $t("message.system_info") }}</h3>
    <div class="info_container">
      <aside class="info_item" v-for="(item, index) in infoItems" :key="index">
        <div class="left" >
          <p class="device-num">
            <template v-if="index == 0">
              <span class="online-num">{{ module_store.online_num }}</span>
              <span class="slash">/</span>
            </template>
            <span class="total-num" :style="{ color: item.color }">{{ item.value }}</span>
            <span class="unit" :style="{ color: item.color }">{{ $t("message.num") }}</span>
          </p>
          <p style="font-size: 12px;">{{ $t(item.label) }}</p>
        </div>
        <div class="right">
          <img :src="item.image" />
        </div>
      </aside>
    </div>
    <span class="border_bg_leftTop"></span>
  </div>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import { moduleStore } from '../../store/module'
import { adminStore } from '../../store/admin'
import { storeToRefs } from 'pinia'
import deviceNumImg from '@/assets/images/deviceNum.png'
import userImg from '@/assets/images/user.png'
import errorNumImg from '@/assets/images/errorNum.png'
const module_store = moduleStore()
const admin_store = adminStore()
const { deviceList } = storeToRefs(module_store)

const infoItems = computed(() => [
  {
    value: module_store.module_num,
    label: 'message.access_device',
    color: '#3b71bf',
    image: deviceNumImg
  },
  {
    value: admin_store.AableSendMsgNum,
    label: 'message.openSms',
    color: '#64bbb7',
    image: userImg
  },
  {
    value: deviceList.value.length,
    label: 'message.monitoring',
    color: '#d498e2',
    image: errorNumImg
  }
])
</script>

<style scoped lang="less">
.system_info {
  height: 90px;
  position: relative;
  border: 0.008rem solid rgba(14,253,255,0.5);
  margin-bottom: 10px;
  padding: 5px 15px;

  h3 {
    color: #fff;
    font-size: 15px;
    height: 30px;
    line-height: 30px;
    padding-left: 10px;
    text-align: left;
  }

  .info_container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: calc(100% - 30px);
    padding-bottom: 2px;
    .info_item {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;
      width: 33%;
   

      .left {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-right: 15px;
        justify-content: center;

        p {
          &:first-child {
            margin-bottom: 5px;
            span {
              display: inline-block;
              font-size: 19px;
              font-weight: bold;
            }
          }
          &:last-child {
            color: #fff;
            font-size: 12px;
          }
        }
      }

      .right {
        display: flex;
        align-items: center;
        justify-content: center;
        img {
          width: 35px;
          height: 35px;
        }
      }
    }
  }

  .border_bg_leftTop {
    position: absolute;
    left: -0.008rem;
    top: -0.04rem;
    width: 0.37rem;
    height: 0.05rem;
    display: block;
    background: #29292f url("@/assets/images/title_left_bg.png") no-repeat;
    background-size: cover;
  }
}
.device-num {
  display: flex;
  align-items: baseline;
  font-size: 14px;
  font-weight: 500;
  justify-content: center;
}
.online-num {
  color: #2cf587;
  font-size: 14px;
  font-weight: bold;
  margin-right: 2px;
}
.slash {
  color: #bbb;
  margin: 0 2px;
  font-size: 16px;
}
.total-num {
  color: #4a90e2;
  font-size: 16px;
  font-weight: bold;
  margin-right: 2px;
}
.unit {
  color: #b0b0b0;
  font-size: 12px;
  margin-left: 2px;
}
</style> 